package cn.tedu.restaurant.service.impl;

import cn.tedu.restaurant.entity.Dishes;
import cn.tedu.restaurant.mapper.DishesMapper;
import cn.tedu.restaurant.service.DishesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author JachinLin
 * @since 2020-10-05
 */
@Service public class DishesServiceImpl extends ServiceImpl<DishesMapper, Dishes> implements DishesService {


    @Autowired @Resource private DishesMapper dishesMapper;

    @Override public List<Dishes> getAllDishes() {
        return dishesMapper.selectAllDishes();
    }

    @Override public List<Dishes> getDishesByType(Integer id) {
        return dishesMapper.selectByType(id);
    }

    @Override public List<Dishes> getDishesByChildType(Integer childType) {
        return dishesMapper.selectByChildType(childType);
    }

    @Override public List<Dishes> getDishesByName(String name) {
        return dishesMapper.selectByName(name);
    }

    @Override public Integer updateTop(Integer uid, Integer topNum, Integer id) {
        Integer topNum1 = dishesMapper.selectById(id).getTopNum();
        return dishesMapper.updateTop(uid,topNum1+topNum,id);
    }

    @Override public Dishes selectByDid(Integer id) {
        return dishesMapper.selectById(id);
    }
}
